/*******************************************************************************
 * Package: com.chris.product.controller
 * Type:    ProductController
 * Date:    2024/3/1 下午2:49
 *
 * Copyright (c) 2024 BOING CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.chris.product.controller;

import com.alibaba.fastjson.JSON;
import com.chris.common.entity.Product;
import com.chris.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO your comment
 *
 * @author Hudesheng
 * @date 2024/3/1 下午2:49
 */
@RestController
@Slf4j
public class ProductController {
    @Autowired
    private ProductService productService;
    
    @GetMapping("/product/{pid}")
    public Product product(@PathVariable("pid") Integer pid) {
        Product product = productService.findById(pid);
        log.info("查询到商品:" + JSON.toJSONString(product));
        return product;
    }
}